'===================================================
'Sub: CopyAFile
'Description: Copies a file
'Where to place code: Module
'Notes: strOrigFile is the file that you want to copy
'       strNewFile is the file that you want to copy strOrigFile to
'       If lngOverwrite is set to a nonzero value (1), the function will fail if the destination file already exists
'       If lngOverwrite is set to 0, the destination file will be overwritten if it exists
'
'http://www.littleguru.com
'==================================================

Public Declare Function CopyFile& Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long)

Public Sub CopyAFile(strOrigFile As String, strNewFile As String, lngOverwrite As Long)
  CopyAFile = CopyFile(OrigFile, NewFile, Overwrite)
  If CopyAFile = 0 Then
    ' Insert Error Handling routine here
    Exit Sub
  End If
End Sub

